1 Imports System.Data.OleDb
2 Public Class frmBillling
3 Dim UserButtons As List(Of Button) = New List(Of Button)
4 Dim s1, s2, s3, s4 As String
5 Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
6 lblDateTime.Text = Now.ToString("dddd, dd MMMM yyyy hh:mm:ss tt")
7 End Sub
8 Sub StartBillNo()
9 Try
10 con = New OleDbConnection(cs)
11 con.Open()
12 cmd = con.CreateCommand()
13 cmd.CommandText = "SELECT StartBillNo from Hotel"
14 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
15 rdr = cmd.ExecuteReader()
16 If rdr.Read() Then
17 txtStartBillNo.Text = rdr.GetValue(0)
18 End If
19 If (rdr IsNot Nothing) Then
20 rdr.Close()
21 End If
22 If con.State = ConnectionState.Open Then
23 con.Close()
24 End If
25 Catch ex As Exception
26 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
27 End Try
28 End Sub
29 Private Sub auto()
30 Try
31 Dim Num As Integer = 0
32 con = New OleDbConnection(cs)
33 con.Open()
34 Dim OleDb As String = ("SELECT MAX(BillID) FROM RestaurantBillingInfo")
35 cmd = New OleDbCommand(OleDb)
36 cmd.Connection = con
37 If (IsDBNull(cmd.ExecuteScalar)) Then
38 lblBillNo.Text = txtStartBillNo.Text
39 Else
40 Num = cmd.ExecuteScalar + 1
41 lblBillNo.Text = Num.ToString
42 End If
43 con.Close()
44 con.Dispose()
45 Catch ex As Exception
46 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
47 End Try
48 End Sub
49 Private Sub auto1()
50 Try
51 Dim Num As Integer = 0
52 con = New OleDbConnection(cs)
53 con.Open()
54 Dim OleDb As String = ("SELECT MAX(TicketID) FROM KOTGeneration")
55 cmd = New OleDbCommand(OleDb)
56 cmd.Connection = con
57 If (IsDBNull(cmd.ExecuteScalar)) Then
58 Num = 1
59 lblKOTNo.Text = Num.ToString
60 Else
61 Num = cmd.ExecuteScalar + 1
62 lblKOTNo.Text = Num.ToString
63 End If
64 con.Close()
65 con.Dispose()
66 Catch ex As Exception
67 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
68 End Try
69 End Sub
70 Sub FillAvailableTables()
71 Try
72 con = New OleDbConnection(cs)
73 con.Open()
74 Dim cmdText1 As String = "SELECT RTRIM(R_Table.TableNo) from R_Table where Status='Activate' Order by TableNo"
75 cmd = New OleDbCommand(cmdText1)
76 cmd.Connection = con
77 rdr = cmd.ExecuteReader()
78 flpTables.Controls.Clear()
79 Do While (rdr.Read())
80 Dim btn As New Button
81 btn.Text = rdr.GetValue(0)
82 btn.TextAlign = ContentAlignment.MiddleCenter
83 btn.BackColor = Color.White
84 btn.ForeColor = Color.Black
85 btn.FlatStyle = FlatStyle.Popup
86 btn.Width = 40
87 btn.Height = 40
88 btn.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
89 UserButtons.Add(btn)
90 flpTables.Controls.Add(btn)
91 AddHandler btn.Click, AddressOf Me.Button2_Click
92 Loop
93 con.Close()
94 Catch ex As Exception
95 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
96 End Try
97 End Sub
98 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
99 Try
100 Dim btn1 As Button = CType(sender, Button)
101 Dim str As String = btn1.Text.Trim()
102 txtTableNo.Text = str
103 cmbGroup.Enabled = True
104 DataGridView1.Rows.Clear()
105 Clear()
106 FillMenuItems()
107 FillGroup()
108 Catch ex As Exception
109 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
110 End Try
111 End Sub
112
113 Private Sub frmBillling_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
114 If e.KeyCode = Keys.Enter Then
115 Me.SelectNextControl(Me.ActiveControl, True, True, True, False) 'for Select Next Control
116 End If
117 If e.KeyCode = Keys.F1 Then
118 e.Handled = True
119 btnNewBill.PerformClick()
120 End If
121 If e.KeyCode = Keys.F2 Then
122 e.Handled = True
123 btnSave.PerformClick()
124 End If
125
126 If e.KeyCode = Keys.F3 Then
127 e.Handled = True
128 btnCancel.PerformClick()
129 End If
130 If e.KeyCode = Keys.F5 Then
131 e.Handled = True
132 btnChangeTable.PerformClick()
133 End If
134 If e.KeyCode = Keys.F4 Then
135 e.Handled = True
136 btnLock.PerformClick()
137 End If
138 If e.KeyCode = Keys.F6 Then
139 e.Handled = True
140 btnBillNote.PerformClick()
141 End If
142 If e.KeyCode = Keys.F7 And btnDeleteRow.Enabled = True Then
143 e.Handled = True
144 btnDeleteRow.PerformClick()
145 End If
146 If e.KeyCode = Keys.F8 Then
147 e.Handled = True
148 btnGetCash.PerformClick()
149 End If
150 If e.KeyCode = Keys.F9 Then
151 e.Handled = True
152 btnItemNote.PerformClick()
153 End If
154 End Sub
155 Private Sub frmBillling_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
156 FillAvailableTables()
157 FillMenuItems1()
158 StartBillNo()
159 End Sub
160
161 Private Sub cmbBillType_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbBillType.KeyDown
162 If e.KeyCode = Keys.Enter Then
163 e.SuppressKeyPress = True
164 cmbGroup.Focus()
165 End If
166 End Sub
167
168 Private Sub cmbBillType_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbBillType.SelectedIndexChanged
169 If cmbBillType.Text = "Home Delivery" Then
170 txtAddressLine1.ReadOnly = False
171 txtAddressLine2.ReadOnly = False
172 txtAddressLine3.ReadOnly = False
173 txtCustomerName.ReadOnly = False
174 txtContactNo.ReadOnly = False
175 FillMenuItems1()
176 Else
177 txtAddressLine1.ReadOnly = True
178 txtAddressLine2.ReadOnly = True
179 txtAddressLine3.ReadOnly = True
180 txtCustomerName.ReadOnly = True
181 txtContactNo.ReadOnly = True
182 End If
183 If cmbBillType.Text = "KOT" Then
184 cmbPaymentMode.Enabled = False
185 txtDiscountPer.ReadOnly = True
186 txtDiscount.ReadOnly = True
187 txtCash.ReadOnly = True
188 Else
189 cmbPaymentMode.Enabled = True
190 txtDiscountPer.ReadOnly = False
191 txtDiscount.ReadOnly = False
192 txtCash.ReadOnly = False
193 End If
194 If cmbBillType.Text = "Takeaway" Then
195 txtTACharges.Visible = True
196 lblTACharges.Visible = True
197 FillMenuItems1()
198 Else
199 txtTACharges.Visible = False
200 lblTACharges.Visible = False
201 End If
202 If cmbBillType.Text = "Home Delivery" Then
203 txtHDCharges.Visible = True
204 lblHDCharges.Visible = True
205 Else
206 txtHDCharges.Visible = False
207 lblHDCharges.Visible = False
208 End If
209 If cmbBillType.Text = "Express Billing" Then
210 FillMenuItems1()
211 End If
212 If cmbBillType.Text = "KOT Billing" Then
213 fillTableNo()
214 End If
215 End Sub
216 Sub Reset()
217 txtAddressLine1.ReadOnly = False
218 txtAddressLine2.ReadOnly = False
219 txtAddressLine3.ReadOnly = False
220 txtCustomerName.ReadOnly = False
221 txtContactNo.ReadOnly = False
222 txtAddressLine1.Text = ""
223 txtAddressLine2.Text = ""
224 txtAddressLine3.Text = ""
225 txtCustomerName.Text = ""
226 txtContactNo.Text = ""
227 txtTableNo.Text = ""
228 cmbBillType.Text = "KOT"
229 cmbPaymentMode.Text = ""
230 cmbGroup.Text = ""
231 cmbGroup.Enabled = False
232 cmbPaymentMode.Enabled = False
233 Clear()
234 DataGridView1.Rows.Clear()
235 btnDeleteRow.Enabled = False
236 txtTACharges.Visible = False
237 txtHDCharges.Visible = False
238 lblTACharges.Visible = False
239 lblHDCharges.Visible = False
240 btnItemNote.Enabled = False
241 txtDiscountPer.ReadOnly = True
242 txtDiscount.ReadOnly = True
243 txtCash.ReadOnly = True
244 DataGridView2.Visible = False
245 fillTableNo()
246 auto()
247 txtTableNo.Focus()
248 End Sub
249
250 Private Sub btnLock_Click(sender As System.Object, e As System.EventArgs) Handles btnLock.Click
251 frmLock.UserID.Text = lblUser.Text
252 frmLock.ShowDialog()
253 frmLock.Password.Focus()
254 End Sub
255
256 Private Sub btnNewBill_Click(sender As System.Object, e As System.EventArgs) Handles btnNewBill.Click
257 Reset()
258 End Sub
259 Sub FillMenuItems()
260 Try
261 con = New OleDbConnection(cs)
262 con.Open()
263 cmd = con.CreateCommand()
264 cmd.CommandText = "SELECT DishName from Dish,R_Table,InventoryType where Dish.InventoryType=InventoryType.Type and R_Table.InventoryType=InventoryType.Type and R_Table.TableNo=@d1 order by 1"
265 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
266 rdr = cmd.ExecuteReader()
267 Dim cmbItem As DataGridViewComboBoxColumn
268 cmbItem = DataGridView1.Columns("Item")
269 cmbItem.Items.Clear()
270 While rdr.Read()
271 cmbItem.Items.Add(rdr(0).ToString())
272 End While
273 If (rdr IsNot Nothing) Then
274 rdr.Close()
275 End If
276 If con.State = ConnectionState.Open Then
277 con.Close()
278 End If
279 Catch ex As Exception
280 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
281 End Try
282 End Sub
283 Sub FillMenuItems1()
284 Try
285 con = New OleDbConnection(cs)
286 con.Open()
287 cmd = con.CreateCommand()
288 cmd.CommandText = "SELECT DishName from Dish order by 1"
289 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
290 rdr = cmd.ExecuteReader()
291 Dim cmbItem As DataGridViewComboBoxColumn
292 cmbItem = DataGridView1.Columns("Item")
293 cmbItem.Items.Clear()
294 While rdr.Read()
295 cmbItem.Items.Add(rdr(0).ToString())
296 End While
297 If (rdr IsNot Nothing) Then
298 rdr.Close()
299 End If
300 If con.State = ConnectionState.Open Then
301 con.Close()
302 End If
303 Catch ex As Exception
304 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
305 End Try
306 End Sub
307 Private Sub comboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
308 Dim selectedIndex As Integer = DirectCast(sender, ComboBox).SelectedIndex
309 End Sub
310
311
312 Private Sub DataGridView1_CellEndEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
313 Try
314 If Len(Trim(cmbBillType.Text)) = 0 Then
315 MessageBox.Show("Please select bill type", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
316 cmbBillType.Focus()
317 Exit Sub
318 End If
319 If cmbBillType.Text = "KOT" Then
320 con = New OleDbConnection(cs)
321 con.Open()
322 cmd = con.CreateCommand()
323 cmd.CommandText = "SELECT DishName,VAT,ST,SC,Discount,Rate from Dish,R_Table,InventoryType,Category where Dish.InventoryType=InventoryType.Type and R_Table.InventoryType=InventoryType.Type and Category.Categoryname=Dish.Category and R_Table.TableNo=@d1 and ItemID=@d2"
324 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
325 cmd.Parameters.AddWithValue("@d2", Val(DataGridView1.Rows(e.RowIndex).Cells("ItemCode").Value))
326 rdr = cmd.ExecuteReader()
327 If rdr.Read() Then
328 DataGridView1.Rows(e.RowIndex).Cells("Item").Value = rdr.GetValue(0)
329 If DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = Nothing Then
330 DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = 1
331 End If
332 DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value = rdr.GetValue(1)
333 DataGridView1.Rows(e.RowIndex).Cells("STPer").Value = rdr.GetValue(2)
334 DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value = rdr.GetValue(3)
335 DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value = rdr.GetValue(4)
336 DataGridView1.Rows(e.RowIndex).Cells("Rate").Value = rdr.GetValue(5)
337
338 Dim num1, num2, num3, num4, num5, num6, num7 As Double
339
340 num1 = Val(DataGridView1.Rows(e.RowIndex).Cells("Qty").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("Rate").Value)
341 num1 = Math.Round(num1, 2)
342 DataGridView1.Rows(e.RowIndex).Cells("Amount").Value = num1
343 num2 = (Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value)) / 100
344 num2 = Math.Round(num2, 2)
345 DataGridView1.Rows(e.RowIndex).Cells("Discount").Value = num2
346 num3 = Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value - Val(txtDiscount.Text))
347 num4 = (Val(DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value) * Val(num3)) / 100
348 num4 = Math.Round(num4, 2)
349 DataGridView1.Rows(e.RowIndex).Cells("VAT").Value = num4
350 num5 = (Val(DataGridView1.Rows(e.RowIndex).Cells("STPer").Value) * Val(num3)) / 100
351 num5 = Math.Round(num5, 2)
352 DataGridView1.Rows(e.RowIndex).Cells("ST").Value = num5
353 num6 = (Val(DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value) * Val(num3)) / 100
354 num5 = Math.Round(num6, 2)
355 DataGridView1.Rows(e.RowIndex).Cells("SC").Value = num6
356 num7 = CDbl(Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("VAT").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("ST").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("SC").Value) + Val(txtTACharges.Text) + Val(txtHDCharges.Text) - Val(txtDiscount.Text) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value))
357 num7 = Math.Round(num7, 2)
358 DataGridView1.Rows(e.RowIndex).Cells("TotalAmount").Value = num7
359 TotalCalc()
360
361 End If
362 If (rdr IsNot Nothing) Then
363 rdr.Close()
364 End If
365 If con.State = ConnectionState.Open Then
366 con.Close()
367 End If
368
369 con = New OleDbConnection(cs)
370 con.Open()
371 cmd = con.CreateCommand()
372 cmd.CommandText = "SELECT ItemID,VAT,ST,SC,Discount,Rate from Dish,R_Table,InventoryType,Category where Dish.InventoryType=InventoryType.Type and R_Table.InventoryType=InventoryType.Type and Category.Categoryname=Dish.Category and R_Table.TableNo=@d1 and DishName=@d2"
373 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
374 cmd.Parameters.AddWithValue("@d2", DataGridView1.Rows(e.RowIndex).Cells("Item").Value)
375 rdr = cmd.ExecuteReader()
376 If rdr.Read() Then
377 DataGridView1.Rows(e.RowIndex).Cells("ItemCode").Value = rdr.GetValue(0)
378 If DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = Nothing Then
379 DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = 1
380 End If
381 DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value = rdr.GetValue(1)
382 DataGridView1.Rows(e.RowIndex).Cells("STPer").Value = rdr.GetValue(2)
383 DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value = rdr.GetValue(3)
384 DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value = rdr.GetValue(4)
385 DataGridView1.Rows(e.RowIndex).Cells("Rate").Value = rdr.GetValue(5)
386
387 Dim num1, num2, num3, num4, num5, num6, num7 As Double
388
389 num1 = Val(DataGridView1.Rows(e.RowIndex).Cells("Qty").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("Rate").Value)
390 num1 = Math.Round(num1, 2)
391 DataGridView1.Rows(e.RowIndex).Cells("Amount").Value = num1
392 num2 = (Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value)) / 100
393 num2 = Math.Round(num2, 2)
394 DataGridView1.Rows(e.RowIndex).Cells("Discount").Value = num2
395 num3 = Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value - Val(txtDiscount.Text))
396 num4 = (Val(DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value) * Val(num3)) / 100
397 num4 = Math.Round(num4, 2)
398 DataGridView1.Rows(e.RowIndex).Cells("VAT").Value = num4
399 num5 = (Val(DataGridView1.Rows(e.RowIndex).Cells("STPer").Value) * Val(num3)) / 100
400 num5 = Math.Round(num5, 2)
401 DataGridView1.Rows(e.RowIndex).Cells("ST").Value = num5
402 num6 = (Val(DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value) * Val(num3)) / 100
403 num5 = Math.Round(num6, 2)
404 DataGridView1.Rows(e.RowIndex).Cells("SC").Value = num6
405 num7 = CDbl(Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("VAT").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("ST").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("SC").Value) + Val(txtTACharges.Text) + Val(txtHDCharges.Text) - Val(txtDiscount.Text) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value))
406 num7 = Math.Round(num7, 2)
407 DataGridView1.Rows(e.RowIndex).Cells("TotalAmount").Value = num7
408 TotalCalc()
409
410 End If
411 If (rdr IsNot Nothing) Then
412 rdr.Close()
413 End If
414 If con.State = ConnectionState.Open Then
415 con.Close()
416 End If
417 End If
418 If cmbBillType.Text = "Takeaway" Or cmbBillType.Text = "Express Billing" Or cmbBillType.Text = "Home Delivery" Then
419 con = New OleDbConnection(cs)
420 con.Open()
421 cmd = con.CreateCommand()
422 cmd.CommandText = "SELECT DishName,VAT,ST,SC,Discount,Rate from Dish,Category where Category.Categoryname=Dish.Category and ItemID=@d2"
423 cmd.Parameters.AddWithValue("@d2", Val(DataGridView1.Rows(e.RowIndex).Cells("ItemCode").Value))
424 rdr = cmd.ExecuteReader()
425 If rdr.Read() Then
426 DataGridView1.Rows(e.RowIndex).Cells("Item").Value = rdr.GetValue(0)
427 If DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = Nothing Then
428 DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = 1
429 End If
430 DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value = rdr.GetValue(1)
431 DataGridView1.Rows(e.RowIndex).Cells("STPer").Value = rdr.GetValue(2)
432 DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value = rdr.GetValue(3)
433 DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value = rdr.GetValue(4)
434 DataGridView1.Rows(e.RowIndex).Cells("Rate").Value = rdr.GetValue(5)
435
436 Dim num1, num2, num3, num4, num5, num6, num7 As Double
437
438 num1 = Val(DataGridView1.Rows(e.RowIndex).Cells("Qty").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("Rate").Value)
439 num1 = Math.Round(num1, 2)
440 DataGridView1.Rows(e.RowIndex).Cells("Amount").Value = num1
441 num2 = (Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value)) / 100
442 num2 = Math.Round(num2, 2)
443 DataGridView1.Rows(e.RowIndex).Cells("Discount").Value = num2
444 num3 = Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value - Val(txtDiscount.Text))
445 num4 = (Val(DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value) * Val(num3)) / 100
446 num4 = Math.Round(num4, 2)
447 DataGridView1.Rows(e.RowIndex).Cells("VAT").Value = num4
448 num5 = (Val(DataGridView1.Rows(e.RowIndex).Cells("STPer").Value) * Val(num3)) / 100
449 num5 = Math.Round(num5, 2)
450 DataGridView1.Rows(e.RowIndex).Cells("ST").Value = num5
451 num6 = (Val(DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value) * Val(num3)) / 100
452 num5 = Math.Round(num6, 2)
453 DataGridView1.Rows(e.RowIndex).Cells("SC").Value = num6
454 num7 = CDbl(Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("VAT").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("ST").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("SC").Value) + Val(txtTACharges.Text) + Val(txtHDCharges.Text) - Val(txtDiscount.Text) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value))
455 num7 = Math.Round(num7, 2)
456 DataGridView1.Rows(e.RowIndex).Cells("TotalAmount").Value = num7
457 TotalCalc()
458
459 End If
460 If (rdr IsNot Nothing) Then
461 rdr.Close()
462 End If
463 If con.State = ConnectionState.Open Then
464 con.Close()
465 End If
466
467 con = New OleDbConnection(cs)
468 con.Open()
469 cmd = con.CreateCommand()
470 cmd.CommandText = "SELECT ItemID,VAT,ST,SC,Discount,Rate from Dish,Category where Category.Categoryname=Dish.Category and DishName=@d2"
471 cmd.Parameters.AddWithValue("@d2", DataGridView1.Rows(e.RowIndex).Cells("Item").Value)
472 rdr = cmd.ExecuteReader()
473 If rdr.Read() Then
474 DataGridView1.Rows(e.RowIndex).Cells("ItemCode").Value = rdr.GetValue(0)
475 If DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = Nothing Then
476 DataGridView1.Rows(e.RowIndex).Cells("Qty").Value = 1
477 End If
478 DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value = rdr.GetValue(1)
479 DataGridView1.Rows(e.RowIndex).Cells("STPer").Value = rdr.GetValue(2)
480 DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value = rdr.GetValue(3)
481 DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value = rdr.GetValue(4)
482 DataGridView1.Rows(e.RowIndex).Cells("Rate").Value = rdr.GetValue(5)
483
484 Dim num1, num2, num3, num4, num5, num6, num7 As Double
485
486 num1 = Val(DataGridView1.Rows(e.RowIndex).Cells("Qty").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("Rate").Value)
487 num1 = Math.Round(num1, 2)
488 DataGridView1.Rows(e.RowIndex).Cells("Amount").Value = num1
489 num2 = (Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) * Val(DataGridView1.Rows(e.RowIndex).Cells("DiscountPer").Value)) / 100
490 num2 = Math.Round(num2, 2)
491 DataGridView1.Rows(e.RowIndex).Cells("Discount").Value = num2
492 num3 = Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value - Val(txtDiscount.Text))
493 num4 = (Val(DataGridView1.Rows(e.RowIndex).Cells("VATPer").Value) * Val(num3)) / 100
494 num4 = Math.Round(num4, 2)
495 DataGridView1.Rows(e.RowIndex).Cells("VAT").Value = num4
496 num5 = (Val(DataGridView1.Rows(e.RowIndex).Cells("STPer").Value) * Val(num3)) / 100
497 num5 = Math.Round(num5, 2)
498 DataGridView1.Rows(e.RowIndex).Cells("ST").Value = num5
499 num6 = (Val(DataGridView1.Rows(e.RowIndex).Cells("SCPer").Value) * Val(num3)) / 100
500 num5 = Math.Round(num6, 2)
501 DataGridView1.Rows(e.RowIndex).Cells("SC").Value = num6
502 num7 = CDbl(Val(DataGridView1.Rows(e.RowIndex).Cells("Amount").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("VAT").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("ST").Value) + Val(DataGridView1.Rows(e.RowIndex).Cells("SC").Value) + Val(txtTACharges.Text) + Val(txtHDCharges.Text) - Val(txtDiscount.Text) - Val(DataGridView1.Rows(e.RowIndex).Cells("Discount").Value))
503 num7 = Math.Round(num7, 2)
504 DataGridView1.Rows(e.RowIndex).Cells("TotalAmount").Value = num7
505 TotalCalc()
506
507 End If
508 If (rdr IsNot Nothing) Then
509 rdr.Close()
510 End If
511 If con.State = ConnectionState.Open Then
512 con.Close()
513 End If
514 End If
515 Catch ex As Exception
516 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
517 End Try
518 End Sub
519 Public Function GrandTotal() As Double
520 Dim sum As Double = 0
521 Try
522 For Each r As DataGridViewRow In Me.DataGridView1.Rows
523 sum = sum + r.Cells(13).Value
524 Next
525 Catch ex As Exception
526 MsgBox(ex.Message)
527 End Try
528 Return sum
529 End Function
530 Public Function TotalST() As Double
531 Dim sum As Double = 0
532 Try
533 For Each r As DataGridViewRow In Me.DataGridView1.Rows
534 sum = sum + r.Cells(8).Value
535 Next
536 Catch ex As Exception
537 MsgBox(ex.Message)
538 End Try
539 Return sum
540 End Function
541 Public Function TotlVAT() As Double
542 Dim sum As Double = 0
543 Try
544 For Each r As DataGridViewRow In Me.DataGridView1.Rows
545 sum = sum + r.Cells(6).Value
546 Next
547 Catch ex As Exception
548 MsgBox(ex.Message)
549 End Try
550 Return sum
551 End Function
552 Public Function TotalSC() As Double
553 Dim sum As Double = 0
554 Try
555 For Each r As DataGridViewRow In Me.DataGridView1.Rows
556 sum = sum + r.Cells(10).Value
557 Next
558 Catch ex As Exception
559 MsgBox(ex.Message)
560 End Try
561 Return sum
562 End Function
563 Public Function TotalItemDiscount() As Double
564 Dim sum As Double = 0
565 Try
566 For Each r As DataGridViewRow In Me.DataGridView1.Rows
567 sum = sum + r.Cells(12).Value
568 Next
569 Catch ex As Exception
570 MsgBox(ex.Message)
571 End Try
572 Return sum
573 End Function
574 Public Function TotalAmt() As Double
575 Dim sum As Double = 0
576 Try
577 For Each r As DataGridViewRow In Me.DataGridView1.Rows
578 sum = sum + r.Cells(4).Value
579 Next
580 Catch ex As Exception
581 MsgBox(ex.Message)
582 End Try
583 Return sum
584 End Function
585
586 Private Sub txtTACharges_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtTACharges.KeyPress
587 Dim keyChar = e.KeyChar
588
589 If Char.IsControl(keyChar) Then
590 'Allow all control characters.
591 ElseIf Char.IsDigit(keyChar) OrElse keyChar = "."c Then
592 Dim text = Me.txtTACharges.Text
593 Dim selectionStart = Me.txtTACharges.SelectionStart
594 Dim selectionLength = Me.txtTACharges.SelectionLength
595
596 text = text.Substring(0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
597
598 If Integer.TryParse(text, New Integer) AndAlso text.Length > 16 Then
599 'Reject an integer that is longer than 16 digits.
600 e.Handled = True
601 ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf("."c) < text.Length - 3 Then
602 'Reject a real number with two many decimal places.
603 e.Handled = False
604 End If
605 Else
606 'Reject all other characters.
607 e.Handled = True
608 End If
609 End Sub
610
611 Private Sub txtHDCharges_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtHDCharges.KeyPress
612 Dim keyChar = e.KeyChar
613
614 If Char.IsControl(keyChar) Then
615 'Allow all control characters.
616 ElseIf Char.IsDigit(keyChar) OrElse keyChar = "."c Then
617 Dim text = Me.txtHDCharges.Text
618 Dim selectionStart = Me.txtHDCharges.SelectionStart
619 Dim selectionLength = Me.txtHDCharges.SelectionLength
620
621 text = text.Substring(0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
622
623 If Integer.TryParse(text, New Integer) AndAlso text.Length > 16 Then
624 'Reject an integer that is longer than 16 digits.
625 e.Handled = True
626 ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf("."c) < text.Length - 3 Then
627 'Reject a real number with two many decimal places.
628 e.Handled = False
629 End If
630 Else
631 'Reject all other characters.
632 e.Handled = True
633 End If
634 End Sub
635
636 Private Sub txtDiscountPer_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtDiscountPer.KeyPress
637 Dim keyChar = e.KeyChar
638
639 If Char.IsControl(keyChar) Then
640 'Allow all control characters.
641 ElseIf Char.IsDigit(keyChar) OrElse keyChar = "."c Then
642 Dim text = Me.txtDiscountPer.Text
643 Dim selectionStart = Me.txtDiscountPer.SelectionStart
644 Dim selectionLength = Me.txtDiscountPer.SelectionLength
645
646 text = text.Substring(0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
647
648 If Integer.TryParse(text, New Integer) AndAlso text.Length > 16 Then
649 'Reject an integer that is longer than 16 digits.
650 e.Handled = True
651 ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf("."c) < text.Length - 3 Then
652 'Reject a real number with two many decimal places.
653 e.Handled = False
654 End If
655 Else
656 'Reject all other characters.
657 e.Handled = True
658 End If
659 End Sub
660
661 Private Sub txtDiscount_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtDiscount.KeyPress
662 Dim keyChar = e.KeyChar
663
664 If Char.IsControl(keyChar) Then
665 'Allow all control characters.
666 ElseIf Char.IsDigit(keyChar) OrElse keyChar = "."c Then
667 Dim text = Me.txtDiscount.Text
668 Dim selectionStart = Me.txtDiscount.SelectionStart
669 Dim selectionLength = Me.txtDiscount.SelectionLength
670
671 text = text.Substring(0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
672
673 If Integer.TryParse(text, New Integer) AndAlso text.Length > 16 Then
674 'Reject an integer that is longer than 16 digits.
675 e.Handled = True
676 ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf("."c) < text.Length - 3 Then
677 'Reject a real number with two many decimal places.
678 e.Handled = False
679 End If
680 Else
681 'Reject all other characters.
682 e.Handled = True
683 End If
684 End Sub
685
686 Sub Compute()
687 Dim num2, num3, num7 As Double
688 num2 = (Val(txtSubTotal.Text) * Val(txtDiscountPer.Text)) / 100
689 num2 = Math.Round(num2, 2)
690 txtDiscount.Text = num2
691 num3 = num2 + Val(txtItemDiscount.Text)
692 num7 = CDbl(Val(txtSubTotal.Text) + Val(txtVAT.Text) + Val(txtServiceTax.Text) + Val(txtTACharges.Text) + Val(txtServiceCharges.Text) + Val(txtHDCharges.Text) - Val(txtDiscount.Text) - Val(txtItemDiscount.Text))
693 num7 = Math.Round(num7, 2)
694 txtGrandTotal.Text = num7
695 End Sub
696
697 Private Sub txtTACharges_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtTACharges.TextChanged
698 Compute()
699 End Sub
700
701 Private Sub txtHDCharges_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtHDCharges.TextChanged
702 Compute()
703 End Sub
704
705 Private Sub txtDiscountPer_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtDiscountPer.TextChanged
706 Compute()
707 End Sub
708
709 Sub Clear()
710 txtSubTotal.Text = "0.00"
711 txtItemDiscount.Text = "0.00"
712 txtDiscountPer.Text = "0.00"
713 txtDiscount.Text = "0.00"
714 txtVAT.Text = "0.00"
715 txtServiceTax.Text = "0.00"
716 txtServiceCharges.Text = "0.00"
717 txtTACharges.Text = "0.00"
718 txtHDCharges.Text = "0.00"
719 txtGrandTotal.Text = "0.00"
720 txtCash.Text = "0.00"
721 txtChange.Text = "0.00"
722 End Sub
723 Sub TotalCalc()
724 Dim m As Double = 0
725 m = TotalAmt()
726 m = Math.Round(m, 2)
727 txtSubTotal.Text = m
728 Compute()
729 Dim j As Double = 0
730 j = TotlVAT()
731 j = Math.Round(j, 2)
732 txtVAT.Text = j
733
734 Dim k As Double = 0
735 k = TotalST()
736 k = Math.Round(k, 2)
737 txtServiceTax.Text = k
738
739 Dim l As Double = 0
740 l = TotalSC()
741 l = Math.Round(l, 2)
742 txtServiceCharges.Text = l
743
744
745
746 Dim n As Double = 0
747 n = TotalItemDiscount()
748 n = Math.Round(n, 2)
749 txtItemDiscount.Text = n
750 Dim i As Double = 0
751 i = GrandTotal()
752 i = Math.Round(i, 2)
753 txtGrandTotal.Text = i
754 End Sub
755
756 Sub Remove()
757 Try
758 For Each row As DataGridViewRow In DataGridView1.SelectedRows
759 DataGridView1.Rows.Remove(row)
760 Next
761 TotalCalc()
762 btnDeleteRow.Enabled = False
763 Catch ex As Exception
764 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
765 End Try
766 End Sub
767 Private Sub btnDeleteRow_Click(sender As System.Object, e As System.EventArgs) Handles btnDeleteRow.Click
768 Remove()
769 End Sub
770
771 Private Sub DataGridView1_MouseClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
772 If DataGridView1.Rows.Count > 0 Then
773 btnDeleteRow.Enabled = True
774 btnItemNote.Enabled = True
775 End If
776
777 End Sub
778
779 Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
780 DataGridView1.Rows.Clear()
781 TotalCalc()
782 btnDeleteRow.Enabled = False
783 End Sub
784
785 Sub Settle()
786 Try
787 If DataGridView1.Rows.Count > 0 Then
788 con = New OleDbConnection(cs)
789 con.Open()
790 Dim cb1 As String = "insert into PosGrouping(Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12,@d13,@d14,@d15)"
791 cmd = New OleDbCommand(cb1)
792 cmd.Connection = con
793 ' Prepare command for repeated execution
794 cmd.Prepare()
795 ' Data to be inserted
796 For Each row As DataGridViewRow In DataGridView1.Rows
797 If Not row.IsNewRow Then
798 cmd.Parameters.AddWithValue("@d1", Val(row.Cells(0).Value))
799 cmd.Parameters.AddWithValue("@d2", row.Cells(1).Value)
800 cmd.Parameters.AddWithValue("@d3", Val(row.Cells(2).Value))
801 cmd.Parameters.AddWithValue("@d4", Val(row.Cells(3).Value))
802 cmd.Parameters.AddWithValue("@d5", Val(row.Cells(4).Value))
803 cmd.Parameters.AddWithValue("@d6", Val(row.Cells(5).Value))
804 cmd.Parameters.AddWithValue("@d7", Val(row.Cells(6).Value))
805 cmd.Parameters.AddWithValue("@d8", Val(row.Cells(7).Value))
806 cmd.Parameters.AddWithValue("@d9", Val(row.Cells(8).Value))
807 cmd.Parameters.AddWithValue("@d10", Val(row.Cells(9).Value))
808 cmd.Parameters.AddWithValue("@d11", Val(row.Cells(10).Value))
809 cmd.Parameters.AddWithValue("@d12", Val(row.Cells(11).Value))
810 cmd.Parameters.AddWithValue("@d13", Val(row.Cells(12).Value))
811 cmd.Parameters.AddWithValue("@d14", Val(row.Cells(13).Value))
812 If row.Cells(14).Value = Nothing Then
813 cmd.Parameters.AddWithValue("@d15", "")
814 Else
815 cmd.Parameters.AddWithValue("@d15", row.Cells(14).Value)
816 End If
817
818 cmd.ExecuteNonQuery()
819 cmd.Parameters.Clear()
820 End If
821 Next
822 con.Close()
823 con = New OleDbConnection(cs)
824 con.Open()
825 cmd = New OleDbCommand("SELECT Col1,Col2,Sum(Col3),Col4,Sum(Col5),(Col6),Sum(Col7),(Col8),Sum(Col9),(Col10),SUM(Col11),(Col12),Sum(Col13),Sum(Col14),Col15 from PosGrouping group by Col1,Col2,Col4,Col6,Col8,Col10,col12,Col15 order by Col2", con)
826 rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
827 DataGridView1.Rows.Clear()
828 While (rdr.Read() = True)
829 DataGridView1.Rows.Add(rdr(0), rdr(1), rdr(2), rdr(3), rdr(4), rdr(5), rdr(6), rdr(7), rdr(8), rdr(9), rdr(10), rdr(11), rdr(12), rdr(13), rdr(14))
830 End While
831 con.Close()
832 con = New OleDbConnection(cs)
833 con.Open()
834 Dim cb2 As String = "delete from PosGrouping"
835 cmd = New OleDbCommand(cb2)
836 cmd.Connection = con
837 cmd.ExecuteNonQuery()
838 con.Close()
839 DataGridView1.ClearSelection()
840 End If
841 Catch ex As Exception
842 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
843 End Try
844 End Sub
845
846 Private Sub btnBillNote_Click(sender As System.Object, e As System.EventArgs) Handles btnBillNote.Click
847 frmNotes1.Reset()
848 frmNotes1.ShowDialog()
849 End Sub
850
851 Private Sub btnItemNote_Click(sender As System.Object, e As System.EventArgs) Handles btnItemNote.Click
852 Try
853 If DataGridView1.Rows.Count > 0 Then
854 Dim dr As DataGridViewRow = DataGridView1.SelectedRows(0)
855 frmNotes.txtNotes.Text = dr.Cells(14).Value
856 frmNotes.ShowDialog()
857 btnItemNote.Enabled = False
858 End If
859 Catch ex As Exception
860 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
861 End Try
862 End Sub
863
864 Private Sub txtTableNo_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTableNo.KeyDown
865 If e.KeyCode = Keys.Enter Then
866 e.SuppressKeyPress = True
867 cmbBillType.Focus()
868 End If
869 End Sub
870
871 Private Sub txtTableNo_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtTableNo.TextChanged
872 Try
873 cmbGroup.Enabled = True
874 DataGridView1.Rows.Clear()
875 Clear()
876 FillMenuItems()
877 FillGroup()
878 Catch ex As Exception
879 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
880 End Try
881 End Sub
882
883
884 Private Sub btnGetCash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetCash.Click
885 frmGetCash.txtCash.Text = ""
886 frmGetCash.ShowDialog()
887 End Sub
888 Sub Calc()
889 If DataGridView1.Rows.Count > 0 Then
890 Dim num As Decimal
891 num = Val(txtCash.Text) - Val(txtGrandTotal.Text)
892 num = Math.Round(num, 2)
893 If num < 0 Then
894 txtChange.Text = "0.00"
895 Else
896 txtChange.Text = num
897 End If
898 End If
899 End Sub
900
901 Private Sub txtCash_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCash.TextChanged
902 Calc()
903 End Sub
904
905 Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
906 Try
907 If Len(Trim(cmbBillType.Text)) = 0 Then
908 MessageBox.Show("Please select bill type", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
909 cmbBillType.Focus()
910 Exit Sub
911 End If
912 If cmbBillType.Text = "KOT" Then
913 If Len(Trim(txtTableNo.Text)) = 0 Then
914 MessageBox.Show("Please enter table no.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
915 txtTableNo.Focus()
916 Exit Sub
917 End If
918 Settle()
919 auto1()
920 con = New OleDbConnection(cs)
921 con.Open()
922 Dim cl As String = "insert into KOTGeneration(TicketID, BillDate, TableNo, GroupName, GrandTotal, OperatorID, BillNote, Status) Values (" & lblKOTNo.Text & ",#" & System.DateTime.Now & "#,@d1,@d2,@d3,@d4,@d5,'Unpaid')"
923 cmd = New OleDbCommand(cl)
924 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
925 cmd.Parameters.AddWithValue("@d2", cmbGroup.Text)
926 cmd.Parameters.AddWithValue("@d3", Val(txtGrandTotal.Text))
927 cmd.Parameters.AddWithValue("@d4", lblUser.Text)
928 cmd.Parameters.AddWithValue("@d5", txtNotes.Text)
929 cmd.Connection = con
930 cmd.ExecuteReader()
931 con.Close()
932 con = New OleDbConnection(cs)
933 con.Open()
934 Dim cb1 As String = "insert into KOTGenerationItems(Ticket_ID, Item_ID, Qty, Rate, Amount, DiscPer, Disc, VATPer, VATAmt, STPer, STAmt, SCPer, SCAmt, TotalAmt, ItemNote) VALUES (" & lblKOTNo.Text & ",@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12,@d13,@d14)"
935 cmd = New OleDbCommand(cb1)
936 cmd.Connection = con
937 ' Prepare command for repeated execution
938 cmd.Prepare()
939 ' Data to be inserted
940 For Each row As DataGridViewRow In DataGridView1.Rows
941 If Not row.IsNewRow Then
942 cmd.Parameters.AddWithValue("@d1", Val(row.Cells(0).Value))
943 cmd.Parameters.AddWithValue("@d2", Val(row.Cells(2).Value))
944 cmd.Parameters.AddWithValue("@d3", Val(row.Cells(3).Value))
945 cmd.Parameters.AddWithValue("@d4", Val(row.Cells(4).Value))
946 cmd.Parameters.AddWithValue("@d5", Val(row.Cells(5).Value))
947 cmd.Parameters.AddWithValue("@d6", Val(row.Cells(6).Value))
948 cmd.Parameters.AddWithValue("@d7", Val(row.Cells(7).Value))
949 cmd.Parameters.AddWithValue("@d8", Val(row.Cells(8).Value))
950 cmd.Parameters.AddWithValue("@d9", Val(row.Cells(9).Value))
951 cmd.Parameters.AddWithValue("@d10", Val(row.Cells(10).Value))
952 cmd.Parameters.AddWithValue("@d11", Val(row.Cells(11).Value))
953 cmd.Parameters.AddWithValue("@d12", Val(row.Cells(12).Value))
954 cmd.Parameters.AddWithValue("@d13", Val(row.Cells(13).Value))
955 If row.Cells(14).Value = "" Then
956 cmd.Parameters.AddWithValue("@d14", "")
957 Else
958 cmd.Parameters.AddWithValue("@d14", row.Cells(14).Value)
959 End If
960 cmd.ExecuteNonQuery()
961 cmd.Parameters.Clear()
962 End If
963 Next
964 con.Close()
965 Dim st As String = "added the new KOT having KOT no. '" & lblKOTNo.Text & "'"
966 LogFunc(lblUser.Text, st)
967 Print()
968 Reset()
969 End If
970
971 If cmbBillType.Text = "KOT Billing" Then
972 If Len(Trim(cmbPaymentMode.Text)) = 0 Then
973 MessageBox.Show("Please select payment mode", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
974 cmbPaymentMode.Focus()
975 Exit Sub
976 End If
977 Settle()
978 auto()
979 con = New OleDbConnection(cs)
980 con.Open()
981 Dim cl As String = "insert into RestaurantBillingInfo(BillId, BillType, BillDate, CustomerName, AddressLine1, AddressLine2, AddressLine3, ContactNo, PaymentMode, SubTotal, ItemDiscount, DiscountPer, Discount, VAT, ServiceTax, ServiceCharges,TACharges, HDCharges, GrandTotal, Cash, Change, OperatorID, BillNote) Values (" & lblBillNo.Text & ",@d1,#" & System.DateTime.Now & "#,@d2,@d3,@d4,@d5,@d6,@d8,@d9,@d10,@d11,@d12,@d13,@d14,@d15,@d16,@d17,@d18,@d19,@d20,@d21,@d22)"
982 cmd = New OleDbCommand(cl)
983 cmd.Parameters.AddWithValue("@d1", cmbBillType.Text)
984 cmd.Parameters.AddWithValue("@d2", txtCustomerName.Text)
985 cmd.Parameters.AddWithValue("@d3", txtAddressLine1.Text)
986 cmd.Parameters.AddWithValue("@d4", txtAddressLine2.Text)
987 cmd.Parameters.AddWithValue("@d5", txtAddressLine3.Text)
988 cmd.Parameters.AddWithValue("@d6", txtContactNo.Text)
989 cmd.Parameters.AddWithValue("@d8", cmbPaymentMode.Text)
990 cmd.Parameters.AddWithValue("@d9", Val(txtSubTotal.Text))
991 cmd.Parameters.AddWithValue("@d10", Val(txtItemDiscount.Text))
992 cmd.Parameters.AddWithValue("@d11", Val(txtDiscountPer.Text))
993 cmd.Parameters.AddWithValue("@d12", Val(txtDiscount.Text))
994 cmd.Parameters.AddWithValue("@d13", Val(txtVAT.Text))
995 cmd.Parameters.AddWithValue("@d14", Val(txtServiceTax.Text))
996 cmd.Parameters.AddWithValue("@d15", Val(txtServiceCharges.Text))
997 cmd.Parameters.AddWithValue("@d16", Val(txtTACharges.Text))
998 cmd.Parameters.AddWithValue("@d17", Val(txtHDCharges.Text))
999 cmd.Parameters.AddWithValue("@d18", Val(txtGrandTotal.Text))
1000 cmd.Parameters.AddWithValue("@d19", Val(txtCash.Text))
1001 cmd.Parameters.AddWithValue("@d20", Val(txtChange.Text))
1002 cmd.Parameters.AddWithValue("@d21", lblUser.Text)
1003 cmd.Parameters.AddWithValue("@d22", txtNotes.Text)
1004 cmd.Connection = con
1005 cmd.ExecuteReader()
1006 con.Close()
1007 con = New OleDbConnection(cs)
1008 con.Open()
1009 Dim cb1 As String = "insert into RestaurantBillingItems(B_ID, Item_ID, Qty, Rate, Amount, DiscPer, Disc, VATPer, VATAmt, STPer, STAmt, SCPer, SCAmt, TotalAmt,TableNo,GroupName) VALUES (" & lblBillNo.Text & ",@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12,@d13,@d14,@d15)"
1010 cmd = New OleDbCommand(cb1)
1011 cmd.Connection = con
1012 ' Prepare command for repeated execution
1013 cmd.Prepare()
1014 ' Data to be inserted
1015 For Each row As DataGridViewRow In DataGridView2.Rows
1016 If Not row.IsNewRow Then
1017 cmd.Parameters.AddWithValue("@d1", Val(row.Cells(0).Value))
1018 cmd.Parameters.AddWithValue("@d2", Val(row.Cells(2).Value))
1019 cmd.Parameters.AddWithValue("@d3", Val(row.Cells(3).Value))
1020 cmd.Parameters.AddWithValue("@d4", Val(row.Cells(4).Value))
1021 cmd.Parameters.AddWithValue("@d5", Val(row.Cells(5).Value))
1022 cmd.Parameters.AddWithValue("@d6", Val(row.Cells(6).Value))
1023 cmd.Parameters.AddWithValue("@d7", Val(row.Cells(7).Value))
1024 cmd.Parameters.AddWithValue("@d8", Val(row.Cells(8).Value))
1025 cmd.Parameters.AddWithValue("@d9", Val(row.Cells(9).Value))
1026 cmd.Parameters.AddWithValue("@d10", Val(row.Cells(10).Value))
1027 cmd.Parameters.AddWithValue("@d11", Val(row.Cells(11).Value))
1028 cmd.Parameters.AddWithValue("@d12", Val(row.Cells(12).Value))
1029 cmd.Parameters.AddWithValue("@d13", Val(row.Cells(13).Value))
1030 cmd.Parameters.AddWithValue("@d14", row.Cells(14).Value)
1031 cmd.Parameters.AddWithValue("@d15", row.Cells(15).Value)
1032 cmd.ExecuteNonQuery()
1033 cmd.Parameters.Clear()
1034 End If
1035 Next
1036 con.Close()
1037 Dim st As String = "added the new restaurant bill having bill no. '" & lblBillNo.Text & "'"
1038 LogFunc(lblUser.Text, st)
1039
1040 For Each row As DataGridViewRow In DataGridView2.Rows
1041 If Not row.IsNewRow Then
1042 con = New OleDbConnection(cs)
1043 con.Open()
1044 Dim cb As String = "update KOTgeneration Set Status='Paid' where TableNo=@d1 and GroupName=@d2"
1045 cmd = New OleDbCommand(cb)
1046 cmd.Connection = con
1047 cmd.Parameters.AddWithValue("@d1", row.Cells(14).Value)
1048 cmd.Parameters.AddWithValue("@d2", row.Cells(15).Value)
1049 cmd.ExecuteReader()
1050 con.Close()
1051 End If
1052 Next
1053 Print1()
1054 Reset()
1055 End If
1056 If cmbBillType.Text = "Home Delivery" Or cmbBillType.Text = "Takeaway" Or cmbBillType.Text = "Express Billing" Then
1057 If Len(Trim(cmbPaymentMode.Text)) = 0 Then
1058 MessageBox.Show("Please select payment mode", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1059 cmbPaymentMode.Focus()
1060 Exit Sub
1061 End If
1062 If cmbBillType.Text = "Home Delivery" Then
1063 If Len(Trim(txtCustomerName.Text)) = 0 Then
1064 MessageBox.Show("Please enter customer name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1065 txtCustomerName.Focus()
1066 Exit Sub
1067 End If
1068 If Len(Trim(txtAddressLine1.Text)) = 0 Then
1069 MessageBox.Show("Please enter address line 1", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1070 txtAddressLine1.Focus()
1071 Exit Sub
1072 End If
1073 If Len(Trim(txtAddressLine2.Text)) = 0 Then
1074 MessageBox.Show("Please enter address line 2", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1075 txtAddressLine2.Focus()
1076 Exit Sub
1077 End If
1078 If Len(Trim(txtContactNo.Text)) = 0 Then
1079 MessageBox.Show("Please enter contact no.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1080 txtContactNo.Focus()
1081 Exit Sub
1082 End If
1083 End If
1084 Settle()
1085 auto()
1086 con = New OleDbConnection(cs)
1087 con.Open()
1088 Dim cl As String = "insert into RestaurantBillingInfo(BillId, BillType, BillDate, CustomerName, AddressLine1, AddressLine2, AddressLine3, ContactNo, PaymentMode, SubTotal, ItemDiscount, DiscountPer, Discount, VAT, ServiceTax, ServiceCharges,TACharges, HDCharges, GrandTotal, Cash, Change, OperatorID, BillNote) Values (" & lblBillNo.Text & ",@d1,#" & System.DateTime.Now & "#,@d2,@d3,@d4,@d5,@d6,@d8,@d9,@d10,@d11,@d12,@d13,@d14,@d15,@d16,@d17,@d18,@d19,@d20,@d21,@d22)"
1089 cmd = New OleDbCommand(cl)
1090 cmd.Parameters.AddWithValue("@d1", cmbBillType.Text)
1091 cmd.Parameters.AddWithValue("@d2", txtCustomerName.Text)
1092 cmd.Parameters.AddWithValue("@d3", txtAddressLine1.Text)
1093 cmd.Parameters.AddWithValue("@d4", txtAddressLine2.Text)
1094 cmd.Parameters.AddWithValue("@d5", txtAddressLine3.Text)
1095 cmd.Parameters.AddWithValue("@d6", txtContactNo.Text)
1096 cmd.Parameters.AddWithValue("@d8", cmbPaymentMode.Text)
1097 cmd.Parameters.AddWithValue("@d9", Val(txtSubTotal.Text))
1098 cmd.Parameters.AddWithValue("@d10", Val(txtItemDiscount.Text))
1099 cmd.Parameters.AddWithValue("@d11", Val(txtDiscountPer.Text))
1100 cmd.Parameters.AddWithValue("@d12", Val(txtDiscount.Text))
1101 cmd.Parameters.AddWithValue("@d13", Val(txtVAT.Text))
1102 cmd.Parameters.AddWithValue("@d14", Val(txtServiceTax.Text))
1103 cmd.Parameters.AddWithValue("@d15", Val(txtServiceCharges.Text))
1104 cmd.Parameters.AddWithValue("@d16", Val(txtTACharges.Text))
1105 cmd.Parameters.AddWithValue("@d17", Val(txtHDCharges.Text))
1106 cmd.Parameters.AddWithValue("@d18", Val(txtGrandTotal.Text))
1107 cmd.Parameters.AddWithValue("@d19", Val(txtCash.Text))
1108 cmd.Parameters.AddWithValue("@d20", Val(txtChange.Text))
1109 cmd.Parameters.AddWithValue("@d21", lblUser.Text)
1110 cmd.Parameters.AddWithValue("@d22", txtNotes.Text)
1111 cmd.Connection = con
1112 cmd.ExecuteReader()
1113 con.Close()
1114 con = New OleDbConnection(cs)
1115 con.Open()
1116 Dim cb1 As String = "insert into RestaurantBillingItems(B_ID, Item_ID, Qty, Rate, Amount, DiscPer, Disc, VATPer, VATAmt, STPer, STAmt, SCPer, SCAmt, TotalAmt, ItemNote) VALUES (" & lblBillNo.Text & ",@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12,@d13,@d14)"
1117 cmd = New OleDbCommand(cb1)
1118 cmd.Connection = con
1119 ' Prepare command for repeated execution
1120 cmd.Prepare()
1121 ' Data to be inserted
1122 For Each row As DataGridViewRow In DataGridView1.Rows
1123 If Not row.IsNewRow Then
1124 cmd.Parameters.AddWithValue("@d1", Val(row.Cells(0).Value))
1125 cmd.Parameters.AddWithValue("@d2", Val(row.Cells(2).Value))
1126 cmd.Parameters.AddWithValue("@d3", Val(row.Cells(3).Value))
1127 cmd.Parameters.AddWithValue("@d4", Val(row.Cells(4).Value))
1128 cmd.Parameters.AddWithValue("@d5", Val(row.Cells(5).Value))
1129 cmd.Parameters.AddWithValue("@d6", Val(row.Cells(6).Value))
1130 cmd.Parameters.AddWithValue("@d7", Val(row.Cells(7).Value))
1131 cmd.Parameters.AddWithValue("@d8", Val(row.Cells(8).Value))
1132 cmd.Parameters.AddWithValue("@d9", Val(row.Cells(9).Value))
1133 cmd.Parameters.AddWithValue("@d10", Val(row.Cells(10).Value))
1134 cmd.Parameters.AddWithValue("@d11", Val(row.Cells(11).Value))
1135 cmd.Parameters.AddWithValue("@d12", Val(row.Cells(12).Value))
1136 cmd.Parameters.AddWithValue("@d13", Val(row.Cells(13).Value))
1137 If row.Cells(14).Value = "" Then
1138 cmd.Parameters.AddWithValue("@d14", "")
1139 Else
1140 cmd.Parameters.AddWithValue("@d14", row.Cells(14).Value)
1141 End If
1142 cmd.ExecuteNonQuery()
1143 cmd.Parameters.Clear()
1144 End If
1145 Next
1146 con.Close()
1147 If cmbBillType.Text = "Express Billing" Then
1148 Print2()
1149 End If
1150 If cmbBillType.Text = "Takeaway" Then
1151 Print3()
1152 End If
1153 If cmbBillType.Text = "Home Delivery" Then
1154 Print4()
1155 End If
1156 Dim st As String = "added the new restaurant bill having bill no. '" & lblBillNo.Text & "'"
1157 LogFunc(lblUser.Text, st)
1158 Reset()
1159 End If
1160
1161
1162 Catch ex As Exception
1163 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
1164 End Try
1165 End Sub
1166
1167 Private Sub txtCash_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCash.KeyPress
1168 Dim keyChar = e.KeyChar
1169
1170 If Char.IsControl(keyChar) Then
1171 'Allow all control characters.
1172 ElseIf Char.IsDigit(keyChar) OrElse keyChar = "."c Then
1173 Dim text = Me.txtCash.Text
1174 Dim selectionStart = Me.txtCash.SelectionStart
1175 Dim selectionLength = Me.txtCash.SelectionLength
1176
1177 text = text.Substring(0, selectionStart) & keyChar & text.Substring(selectionStart + selectionLength)
1178
1179 If Integer.TryParse(text, New Integer) AndAlso text.Length > 16 Then
1180 'Reject an integer that is longer than 16 digits.
1181 e.Handled = True
1182 ElseIf Double.TryParse(text, New Double) AndAlso text.IndexOf("."c) < text.Length - 3 Then
1183 'Reject a real number with two many decimal places.
1184 e.Handled = False
1185 End If
1186 Else
1187 'Reject all other characters.
1188 e.Handled = True
1189 End If
1190 End Sub
1191
1192 Private Sub btnChangeTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeTable.Click
1193 Try
1194 If txtTableNo.Text = "" Then
1195 MessageBox.Show("Please select table", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
1196 Exit Sub
1197 End If
1198 con = New OleDbConnection(cs)
1199 con.Open()
1200 Dim ct As String = "Select TableNo from KOTGeneration where Status='Unpaid' and TableNo=@d1"
1201 cmd = New OleDbCommand(ct)
1202 cmd.Connection = con
1203 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
1204 rdr = cmd.ExecuteReader()
1205 If Not rdr.Read() Then
1206 frmCustomDialog1.ShowDialog()
1207 If (rdr IsNot Nothing) Then
1208 rdr.Close()
1209 End If
1210 txtTableNo.Text = ""
1211 Return
1212 End If
1213 frmAvailableTables.lblTable.Text = txtTableNo.Text.Trim()
1214 frmAvailableTables.ShowDialog()
1215 Catch ex As Exception
1216 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
1217 End Try
1218 End Sub
1219 Sub FillGroup()
1220 Try
1221 cmbGroup.Text = ""
1222 con = New OleDbConnection(cs)
1223 con.Open()
1224 cmd = New OleDbCommand("Select distinct RTRIM(GroupName) from KOTgeneration where TableNo=@d1 and Status='Unpaid' order by 1", con)
1225 cmd.Parameters.AddWithValue("@d1", txtTableNo.Text)
1226 rdr = cmd.ExecuteReader()
1227 cmbGroup.Items.Clear()
1228 While rdr.Read()
1229 cmbGroup.Items.Add(rdr(0))
1230 End While
1231 con.Close()
1232 Catch ex As Exception
1233 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
1234 End Try
1235 End Sub
1236
1237 Private Sub lvTable_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lvTable.ItemChecked
1238 Try
1239
1240 If lvTable.CheckedItems.Count > 0 Then
1241 Dim Condition As String = ""
1242 Dim Condition1 As String = ""
1243 For I = 0 To lvTable.CheckedItems.Count - 1
1244
1245 Condition += String.Format("'{0}',", lvTable.CheckedItems(I).Text)
1246 Condition1 += String.Format("'{0}',", lvTable.CheckedItems(I).SubItems(1).Text)
1247 Next
1248 Condition = Condition.Substring(0, Condition.Length - 1)
1249 Condition1 = Condition1.Substring(0, Condition1.Length - 1)
1250 DataGridView2.Visible = True
1251 con = New OleDbConnection(cs)
1252 con.Open()
1253 Dim OleDb As String = "Select Item_ID,DishName, SUM(Qty), KOTGenerationItems.Rate, SUM(Amount), DiscPer, SUM(Disc), VATPer, SUM(VATAmt), STPer, SUM(STAmt), SCPer, SUM(SCAmt), SUM(TotalAmt),TableNo,GroupName from KOTGeneration,KOTGenerationItems,Dish where KOTGeneration.TicketID=KOTGenerationItems.Ticket_ID and KOTGenerationItems.Item_ID=Dish.ItemID and TableNo in (" & Condition & ") and GroupName in (" & Condition1 & ") group by Item_ID,DishName,KOTGenerationItems.Rate,DiscPer,VATPer,STPer,SCPer,TableNo,GroupName order by TableNo"
1254 cmd = New OleDbCommand(OleDb, con)
1255 rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
1256 DataGridView2.Rows.Clear()
1257 While (rdr.Read() = True)
1258 DataGridView2.Rows.Add(rdr(0), rdr(1), rdr(2), rdr(3), rdr(4), rdr(5), rdr(6), rdr(7), rdr(8), rdr(9), rdr(10), rdr(11), rdr(12), rdr(13), rdr(14), rdr(15))
1259 End While
1260 con.Close()
1261 txtCash.Text = "0.00"
1262 TotalCalc1()
1263 Calc()
1264 Else
1265 Clear()
1266 DataGridView2.Rows.Clear()
1267 DataGridView2.Visible = False
1268 End If
1269 Catch ex As Exception
1270 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
1271 End Try
1272 End Sub
1273 Sub fillTableNo()
1274 Try
1275 Dim _with1 = lvTable
1276 _with1.Clear()
1277 _with1.Columns.Add("Table No.", 120, HorizontalAlignment.Left)
1278 _with1.Columns.Add("Group/Customer", 240, HorizontalAlignment.Left)
1279 con = New OleDbConnection(cs)
1280 con.Open()
1281 cmd = New OleDbCommand("SELECT distinct RTRIM(R_Table.TableNo),RTRIM(GroupName) FROM R_Table,KOTGeneration where KOTGeneration.TableNo=R_Table.TableNo and KOTgeneration.Status='Unpaid' and R_Table.Status='Activate'", con)
1282 rdr = cmd.ExecuteReader()
1283 While rdr.Read()
1284 Dim item = New ListViewItem()
1285 item.Text = rdr(0).ToString().Trim()
1286 item.SubItems.Add(rdr(1).ToString().Trim())
1287 lvTable.Items.Add(item)
1288 End While
1289 con.Close()
1290 Catch ex As Exception
1291 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
1292 End Try
1293 End Sub
1294 Public Function GrandTotal1() As Double
1295 Dim sum As Double = 0
1296 Try
1297 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1298 sum = sum + r.Cells(13).Value
1299 Next
1300 Catch ex As Exception
1301 MsgBox(ex.Message)
1302 End Try
1303 Return sum
1304 End Function
1305 Public Function TotalST1() As Double
1306 Dim sum As Double = 0
1307 Try
1308 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1309 sum = sum + r.Cells(8).Value
1310 Next
1311 Catch ex As Exception
1312 MsgBox(ex.Message)
1313 End Try
1314 Return sum
1315 End Function
1316 Public Function TotlVAT1() As Double
1317 Dim sum As Double = 0
1318 Try
1319 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1320 sum = sum + r.Cells(6).Value
1321 Next
1322 Catch ex As Exception
1323 MsgBox(ex.Message)
1324 End Try
1325 Return sum
1326 End Function
1327 Public Function TotalSC1() As Double
1328 Dim sum As Double = 0
1329 Try
1330 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1331 sum = sum + r.Cells(10).Value
1332 Next
1333 Catch ex As Exception
1334 MsgBox(ex.Message)
1335 End Try
1336 Return sum
1337 End Function
1338 Public Function TotalItemDiscount1() As Double
1339 Dim sum As Double = 0
1340 Try
1341 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1342 sum = sum + r.Cells(12).Value
1343 Next
1344 Catch ex As Exception
1345 MsgBox(ex.Message)
1346 End Try
1347 Return sum
1348 End Function
1349 Public Function TotalAmt1() As Double
1350 Dim sum As Double = 0
1351 Try
1352 For Each r As DataGridViewRow In Me.DataGridView2.Rows
1353 sum = sum + r.Cells(4).Value
1354 Next
1355 Catch ex As Exception
1356 MsgBox(ex.Message)
1357 End Try
1358 Return sum
1359 End Function
1360 Sub TotalCalc1()
1361 Dim m As Double = 0
1362 m = TotalAmt1()
1363 m = Math.Round(m, 2)
1364 txtSubTotal.Text = m
1365 Compute()
1366 Dim j As Double = 0
1367 j = TotlVAT1()
1368 j = Math.Round(j, 2)
1369 txtVAT.Text = j
1370
1371 Dim k As Double = 0
1372 k = TotalST1()
1373 k = Math.Round(k, 2)
1374 txtServiceTax.Text = k
1375
1376 Dim l As Double = 0
1377 l = TotalSC1()
1378 l = Math.Round(l, 2)
1379 txtServiceCharges.Text = l
1380 Dim n As Double = 0
1381 n = TotalItemDiscount1()
1382 n = Math.Round(n, 2)
1383 txtItemDiscount.Text = n
1384 Dim i As Double = 0
1385 i = GrandTotal1()
1386 i = Math.Round(i, 2)
1387 txtGrandTotal.Text = i
1388 End Sub
1389
1390 Private Sub cmbPaymentMode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPaymentMode.SelectedIndexChanged
1391 If cmbPaymentMode.Text = "Cash" Then
1392 txtCash.Text = "0.00"
1393 Else
1394 txtCash.Text = txtGrandTotal.Text
1395 Calc()
1396 End If
1397 End Sub
1398
1399 Sub PrintKOT()
1400 Cursor = Cursors.WaitCursor
1401 Timer2.Enabled = True
1402 Dim rpt As New rptRestaurantPOSKOTInvoice 'The report you created.
1403 Dim myConnection As OleDbConnection
1404 Dim MyCommand, MyCommand1 As New OleDbCommand()
1405 Dim myDA, myDA1 As New OleDbDataAdapter()
1406 Dim myDS As New DataSet 'The DataSet you created.
1407 myConnection = New OleDbConnection(cs)
1408 MyCommand.Connection = myConnection
1409 MyCommand1.Connection = myConnection
1410 MyCommand.CommandText = "SELECT KOTGeneration.TicketID, KOTGeneration.BillDate, KOTGeneration.TableNo, KOTGeneration.GroupName, KOTGeneration.GrandTotal, KOTGeneration.OperatorID, KOTGeneration.BillNote, KOTGeneration.Status,KOTGenerationItems.KOT_ID, KOTGenerationItems.Ticket_ID, KOTGenerationItems.Item_ID, KOTGenerationItems.Qty, KOTGenerationItems.Rate, KOTGenerationItems.Amount, KOTGenerationItems.DiscPer,KOTGenerationItems.Disc, KOTGenerationItems.VATPer, KOTGenerationItems.VATAmt, KOTGenerationItems.STPer, KOTGenerationItems.STAmt, KOTGenerationItems.SCPer, KOTGenerationItems.SCAmt,KOTGenerationItems.TotalAmt, KOTGenerationItems.ItemNote, Dish.ItemID, Dish.Dishname, Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount FROM ((KOTGeneration INNER JOIN KOTGenerationItems ON KOTGeneration.TicketID = KOTGenerationItems.Ticket_ID) INNER JOIN Dish ON KOTGenerationItems.Item_ID = Dish.ItemID) where TicketID=" & lblKOTNo.Text & ""
1411 MyCommand1.CommandText = "SELECT * from Hotel"
1412 MyCommand.CommandType = CommandType.Text
1413 MyCommand1.CommandType = CommandType.Text
1414 myDA.SelectCommand = MyCommand
1415 myDA1.SelectCommand = MyCommand1
1416 myDA.Fill(myDS, "KOTGeneration")
1417 myDA.Fill(myDS, "KOTGenerationItems")
1418 myDA.Fill(myDS, "Dish")
1419 myDA1.Fill(myDS, "Hotel")
1420 rpt.SetDataSource(myDS)
1421 con = New OleDbConnection(cs)
1422 con.Open()
1423 cmd = con.CreateCommand()
1424 cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where PrinterType='Ticket Printer' and IsEnabled='Yes'"
1425 rdr = cmd.ExecuteReader()
1426 If rdr.Read() Then
1427 s2 = rdr.GetValue(0)
1428 rpt.PrintOptions.PrinterName = s2
1429 rpt.PrintToPrinter(1, False, 0, 0)
1430 End If
1431 If (rdr IsNot Nothing) Then
1432 rdr.Close()
1433 End If
1434 If con.State = ConnectionState.Open Then
1435 con.Close()
1436 End If
1437 End Sub
1438 Sub PrintKOT_Kitchen()
1439 Dim CN As New OleDbConnection(cs)
1440 CN.Open()
1441 adp = New OleDbDataAdapter()
1442 adp.SelectCommand = New OleDbCommand("SELECT DISTINCT Kitchen.KitchenName FROM (((Dish INNER JOIN Kitchen ON Dish.Kitchen = Kitchen.KitchenName) INNER JOIN KOTGenerationItems ON Dish.ItemID = KOTGenerationItems.Item_ID) INNER JOIN KOTGeneration ON KOTGenerationItems.Ticket_ID = KOTGeneration.TicketID) where TicketID=" & lblKOTNo.Text & "", CN)
1443 ds = New DataSet("ds")
1444 adp.Fill(ds)
1445 Dim dtable As DataTable = ds.Tables(0)
1446 CBox.Items.Clear()
1447 For Each drow As DataRow In dtable.Rows
1448 CBox.Items.Add(drow(0).ToString())
1449 Next
1450 For Each item As String In CBox.Items
1451 Cursor = Cursors.WaitCursor
1452 Timer2.Enabled = True
1453 Dim rpt As New rptRestaurantPOSKOTInvoice_Kitchen 'The report you created.
1454 Dim myConnection As OleDbConnection
1455 Dim MyCommand, MyCommand1 As New OleDbCommand()
1456 Dim myDA, myDA1 As New OleDbDataAdapter()
1457 Dim myDS As New DataSet 'The DataSet you created.
1458 myConnection = New OleDbConnection(cs)
1459 MyCommand.Connection = myConnection
1460 MyCommand1.Connection = myConnection
1461 MyCommand.CommandText = "SELECT KOTGeneration.TicketID, KOTGeneration.BillDate, KOTGeneration.TableNo, KOTGeneration.GroupName, KOTGeneration.GrandTotal, KOTGeneration.OperatorID, KOTGeneration.BillNote, KOTGeneration.Status,KOTGenerationItems.KOT_ID, KOTGenerationItems.Ticket_ID, KOTGenerationItems.Item_ID, KOTGenerationItems.Qty, KOTGenerationItems.Rate, KOTGenerationItems.Amount, KOTGenerationItems.DiscPer,KOTGenerationItems.Disc, KOTGenerationItems.VATPer, KOTGenerationItems.VATAmt, KOTGenerationItems.STPer, KOTGenerationItems.STAmt, KOTGenerationItems.SCPer, KOTGenerationItems.SCAmt,KOTGenerationItems.TotalAmt, KOTGenerationItems.ItemNote, Dish.ItemID, Dish.Dishname, Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount FROM ((KOTGeneration INNER JOIN KOTGenerationItems ON KOTGeneration.TicketID = KOTGenerationItems.Ticket_ID) INNER JOIN Dish ON KOTGenerationItems.Item_ID = Dish.ItemID) where TicketID=" & lblKOTNo.Text & " and Kitchen=@d1"
1462 MyCommand.Parameters.AddWithValue("@d1", item)
1463 MyCommand1.CommandText = "SELECT * from Hotel"
1464 MyCommand.CommandType = CommandType.Text
1465 MyCommand1.CommandType = CommandType.Text
1466 myDA.SelectCommand = MyCommand
1467 myDA1.SelectCommand = MyCommand1
1468 myDA.Fill(myDS, "KOTGeneration")
1469 myDA.Fill(myDS, "KOTGenerationItems")
1470 myDA.Fill(myDS, "Dish")
1471 myDA1.Fill(myDS, "Hotel")
1472 rpt.SetDataSource(myDS)
1473 con = New OleDbConnection(cs)
1474 con.Open()
1475 cmd = con.CreateCommand()
1476 cmd.CommandText = "SELECT RTRIM(Printer) from Kitchen where KitchenName=@d1 and IsEnabled='Yes'"
1477 cmd.Parameters.AddWithValue("@d1", item)
1478 rdr = cmd.ExecuteReader()
1479 If rdr.Read() Then
1480 s1 = rdr.GetValue(0)
1481 rpt.PrintOptions.PrinterName = s1
1482 rpt.PrintToPrinter(1, False, 0, 0)
1483 End If
1484 If (rdr IsNot Nothing) Then
1485 rdr.Close()
1486 End If
1487 If con.State = ConnectionState.Open Then
1488 con.Close()
1489 End If
1490 Next
1491
1492 End Sub
1493 Sub Print()
1494 Try
1495 PrintKOT()
1496 PrintKOT_Kitchen()
1497 Catch ex As Exception
1498 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
1499 End Try
1500 End Sub
1501 Sub Print1()
1502 Cursor = Cursors.WaitCursor
1503 Timer2.Enabled = True
1504 Dim rpt As New rptRestaurantPOSFinalBillKOTInvoice 'The report you created.
1505 Dim myConnection As OleDbConnection
1506 Dim MyCommand, MyCommand1 As New OleDbCommand()
1507 Dim myDA, myDA1 As New OleDbDataAdapter()
1508 Dim myDS As New DataSet 'The DataSet you created.
1509 myConnection = New OleDbConnection(cs)
1510 MyCommand.Connection = myConnection
1511 MyCommand1.Connection = myConnection
1512 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1513 MyCommand1.CommandText = "SELECT * from Hotel"
1514 MyCommand.CommandType = CommandType.Text
1515 MyCommand1.CommandType = CommandType.Text
1516 myDA.SelectCommand = MyCommand
1517 myDA1.SelectCommand = MyCommand1
1518 myDA.Fill(myDS, "RestaurantBillingInfo")
1519 myDA.Fill(myDS, "RestaurantBillingItems")
1520 myDA.Fill(myDS, "Dish")
1521 myDA1.Fill(myDS, "Hotel")
1522 rpt.SetDataSource(myDS)
1523 con = New OleDbConnection(cs)
1524 con.Open()
1525 cmd = con.CreateCommand()
1526 cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where PrinterType='Invoice Printer' and IsEnabled='Yes'"
1527 rdr = cmd.ExecuteReader()
1528 If rdr.Read() Then
1529 s2 = rdr.GetValue(0)
1530 rpt.PrintOptions.PrinterName = s2
1531 rpt.PrintToPrinter(1, False, 0, 0)
1532 End If
1533 If (rdr IsNot Nothing) Then
1534 rdr.Close()
1535 End If
1536 If con.State = ConnectionState.Open Then
1537 con.Close()
1538 End If
1539 End Sub
1540 Sub PrintEB()
1541 Cursor = Cursors.WaitCursor
1542 Timer2.Enabled = True
1543 Dim rpt As New rptRestaurantPOSEBInvoice 'The report you created.
1544 Dim myConnection As OleDbConnection
1545 Dim MyCommand, MyCommand1 As New OleDbCommand()
1546 Dim myDA, myDA1 As New OleDbDataAdapter()
1547 Dim myDS As New DataSet 'The DataSet you created.
1548 myConnection = New OleDbConnection(cs)
1549 MyCommand.Connection = myConnection
1550 MyCommand1.Connection = myConnection
1551 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1552 MyCommand1.CommandText = "SELECT * from Hotel"
1553 MyCommand.CommandType = CommandType.Text
1554 MyCommand1.CommandType = CommandType.Text
1555 myDA.SelectCommand = MyCommand
1556 myDA1.SelectCommand = MyCommand1
1557 myDA.Fill(myDS, "RestaurantBillingInfo")
1558 myDA.Fill(myDS, "RestaurantBillingItems")
1559 myDA.Fill(myDS, "Dish")
1560 myDA1.Fill(myDS, "Hotel")
1561 rpt.SetDataSource(myDS)
1562 con = New OleDbConnection(cs)
1563 con.Open()
1564 cmd = con.CreateCommand()
1565 cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where PrinterType='Invoice Printer' and IsEnabled='Yes'"
1566 rdr = cmd.ExecuteReader()
1567 If rdr.Read() Then
1568 s2 = rdr.GetValue(0)
1569 rpt.PrintOptions.PrinterName = s2
1570 rpt.PrintToPrinter(1, False, 0, 0)
1571 End If
1572 If (rdr IsNot Nothing) Then
1573 rdr.Close()
1574 End If
1575 If con.State = ConnectionState.Open Then
1576 con.Close()
1577 End If
1578 End Sub
1579
1580 Sub PrintEB_Kitchen()
1581 Dim CN As New OleDbConnection(cs)
1582 CN.Open()
1583 adp = New OleDbDataAdapter()
1584 adp.SelectCommand = New OleDbCommand("SELECT DISTINCT Kitchen.KitchenName FROM (((Dish INNER JOIN Kitchen ON Dish.Kitchen = Kitchen.KitchenName) INNER JOIN RestaurantBillingItems ON Dish.ItemID = RestaurantBillingItems.Item_ID) INNER JOIN RestaurantBillingInfo ON RestaurantBillingItems.B_ID = RestaurantBillingInfo.BillID) where BillID=" & lblBillNo.Text & "", CN)
1585 ds = New DataSet("ds")
1586 adp.Fill(ds)
1587 Dim dtable As DataTable = ds.Tables(0)
1588 CBox.Items.Clear()
1589 For Each drow As DataRow In dtable.Rows
1590 CBox.Items.Add(drow(0).ToString())
1591 Next
1592 For Each item As String In CBox.Items
1593 Cursor = Cursors.WaitCursor
1594 Timer2.Enabled = True
1595 Dim rpt As New rptRestaurantPOSEBInvoice_Kitchen 'The report you created.
1596 Dim myConnection As OleDbConnection
1597 Dim MyCommand, MyCommand1 As New OleDbCommand()
1598 Dim myDA, myDA1 As New OleDbDataAdapter()
1599 Dim myDS As New DataSet 'The DataSet you created.
1600 myConnection = New OleDbConnection(cs)
1601 MyCommand.Connection = myConnection
1602 MyCommand1.Connection = myConnection
1603 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1604 MyCommand.Parameters.AddWithValue("@d1", item)
1605 MyCommand1.CommandText = "SELECT * from Hotel"
1606 MyCommand.CommandType = CommandType.Text
1607 MyCommand1.CommandType = CommandType.Text
1608 myDA.SelectCommand = MyCommand
1609 myDA1.SelectCommand = MyCommand1
1610 myDA.Fill(myDS, "RestaurantBillingInfo")
1611 myDA.Fill(myDS, "RestaurantBillingItems")
1612 myDA.Fill(myDS, "Dish")
1613 myDA1.Fill(myDS, "Hotel")
1614 rpt.SetDataSource(myDS)
1615 con = New OleDbConnection(cs)
1616 con.Open()
1617 cmd = con.CreateCommand()
1618 cmd.CommandText = "SELECT RTRIM(Printer) from Kitchen where KitchenName=@d1 and IsEnabled='Yes'"
1619 cmd.Parameters.AddWithValue("@d1", item)
1620 rdr = cmd.ExecuteReader()
1621 If rdr.Read() Then
1622 s1 = rdr.GetValue(0)
1623 rpt.PrintOptions.PrinterName = s1
1624 rpt.PrintToPrinter(1, False, 0, 0)
1625 End If
1626 If (rdr IsNot Nothing) Then
1627 rdr.Close()
1628 End If
1629 If con.State = ConnectionState.Open Then
1630 con.Close()
1631 End If
1632 Next
1633
1634 End Sub
1635 Sub Print2()
1636 PrintEB()
1637 PrintEB_Kitchen()
1638 End Sub
1639 Sub PrintTA()
1640 Cursor = Cursors.WaitCursor
1641 Timer2.Enabled = True
1642 Dim rpt As New rptRestaurantPOSTAInvoice 'The report you created.
1643 Dim myConnection As OleDbConnection
1644 Dim MyCommand, MyCommand1 As New OleDbCommand()
1645 Dim myDA, myDA1 As New OleDbDataAdapter()
1646 Dim myDS As New DataSet 'The DataSet you created.
1647 myConnection = New OleDbConnection(cs)
1648 MyCommand.Connection = myConnection
1649 MyCommand1.Connection = myConnection
1650 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1651 MyCommand1.CommandText = "SELECT * from Hotel"
1652 MyCommand.CommandType = CommandType.Text
1653 MyCommand1.CommandType = CommandType.Text
1654 myDA.SelectCommand = MyCommand
1655 myDA1.SelectCommand = MyCommand1
1656 myDA.Fill(myDS, "RestaurantBillingInfo")
1657 myDA.Fill(myDS, "RestaurantBillingItems")
1658 myDA.Fill(myDS, "Dish")
1659 myDA1.Fill(myDS, "Hotel")
1660 rpt.SetDataSource(myDS)
1661 con = New OleDbConnection(cs)
1662 con.Open()
1663 cmd = con.CreateCommand()
1664 cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where PrinterType='Invoice Printer' and IsEnabled='Yes'"
1665 rdr = cmd.ExecuteReader()
1666 If rdr.Read() Then
1667 s2 = rdr.GetValue(0)
1668 rpt.PrintOptions.PrinterName = s2
1669 rpt.PrintToPrinter(1, False, 0, 0)
1670 End If
1671 If (rdr IsNot Nothing) Then
1672 rdr.Close()
1673 End If
1674 If con.State = ConnectionState.Open Then
1675 con.Close()
1676 End If
1677 End Sub
1678 Sub PrintTA_Kitchen()
1679 Dim CN As New OleDbConnection(cs)
1680 CN.Open()
1681 adp = New OleDbDataAdapter()
1682 adp.SelectCommand = New OleDbCommand("SELECT DISTINCT Kitchen.KitchenName FROM (((Dish INNER JOIN Kitchen ON Dish.Kitchen = Kitchen.KitchenName) INNER JOIN RestaurantBillingItems ON Dish.ItemID = RestaurantBillingItems.Item_ID) INNER JOIN RestaurantBillingInfo ON RestaurantBillingItems.B_ID = RestaurantBillingInfo.BillID) where BillID=" & lblBillNo.Text & "", CN)
1683 ds = New DataSet("ds")
1684 adp.Fill(ds)
1685 Dim dtable As DataTable = ds.Tables(0)
1686 CBox.Items.Clear()
1687 For Each drow As DataRow In dtable.Rows
1688 CBox.Items.Add(drow(0).ToString())
1689 Next
1690 For Each item As String In CBox.Items
1691 Cursor = Cursors.WaitCursor
1692 Timer2.Enabled = True
1693 Dim rpt As New rptRestaurantPOSTAInvoice_Kitchen 'The report you created.
1694 Dim myConnection As OleDbConnection
1695 Dim MyCommand, MyCommand1 As New OleDbCommand()
1696 Dim myDA, myDA1 As New OleDbDataAdapter()
1697 Dim myDS As New DataSet 'The DataSet you created.
1698 myConnection = New OleDbConnection(cs)
1699 MyCommand.Connection = myConnection
1700 MyCommand1.Connection = myConnection
1701 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1702 MyCommand.Parameters.AddWithValue("@d1", item)
1703 MyCommand1.CommandText = "SELECT * from Hotel"
1704 MyCommand.CommandType = CommandType.Text
1705 MyCommand1.CommandType = CommandType.Text
1706 myDA.SelectCommand = MyCommand
1707 myDA1.SelectCommand = MyCommand1
1708 myDA.Fill(myDS, "RestaurantBillingInfo")
1709 myDA.Fill(myDS, "RestaurantBillingItems")
1710 myDA.Fill(myDS, "Dish")
1711 myDA1.Fill(myDS, "Hotel")
1712 rpt.SetDataSource(myDS)
1713 con = New OleDbConnection(cs)
1714 con.Open()
1715 cmd = con.CreateCommand()
1716 cmd.CommandText = "SELECT RTRIM(Printer) from Kitchen where KitchenName=@d1 and IsEnabled='Yes'"
1717 cmd.Parameters.AddWithValue("@d1", item)
1718 rdr = cmd.ExecuteReader()
1719 If rdr.Read() Then
1720 s1 = rdr.GetValue(0)
1721 rpt.PrintOptions.PrinterName = s1
1722 rpt.PrintToPrinter(1, False, 0, 0)
1723 End If
1724 If (rdr IsNot Nothing) Then
1725 rdr.Close()
1726 End If
1727 If con.State = ConnectionState.Open Then
1728 con.Close()
1729 End If
1730 Next
1731
1732 End Sub
1733 Sub Print3()
1734 PrintTA()
1735 PrintTA_Kitchen()
1736 End Sub
1737 Sub PrintHD()
1738 Cursor = Cursors.WaitCursor
1739 Timer2.Enabled = True
1740 Dim rpt As New rptRestaurantPOSHDInvoice 'The report you created.
1741 Dim myConnection As OleDbConnection
1742 Dim MyCommand, MyCommand1 As New OleDbCommand()
1743 Dim myDA, myDA1 As New OleDbDataAdapter()
1744 Dim myDS As New DataSet 'The DataSet you created.
1745 myConnection = New OleDbConnection(cs)
1746 MyCommand.Connection = myConnection
1747 MyCommand1.Connection = myConnection
1748 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1749 MyCommand1.CommandText = "SELECT * from Hotel"
1750 MyCommand.CommandType = CommandType.Text
1751 MyCommand1.CommandType = CommandType.Text
1752 myDA.SelectCommand = MyCommand
1753 myDA1.SelectCommand = MyCommand1
1754 myDA.Fill(myDS, "RestaurantBillingInfo")
1755 myDA.Fill(myDS, "RestaurantBillingItems")
1756 myDA.Fill(myDS, "Dish")
1757 myDA1.Fill(myDS, "Hotel")
1758 rpt.SetDataSource(myDS)
1759 con = New OleDbConnection(cs)
1760 con.Open()
1761 cmd = con.CreateCommand()
1762 cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where PrinterType='Invoice Printer' and IsEnabled='Yes'"
1763 rdr = cmd.ExecuteReader()
1764 If rdr.Read() Then
1765 s2 = rdr.GetValue(0)
1766 rpt.PrintOptions.PrinterName = s2
1767 rpt.PrintToPrinter(1, False, 0, 0)
1768 End If
1769 If (rdr IsNot Nothing) Then
1770 rdr.Close()
1771 End If
1772 If con.State = ConnectionState.Open Then
1773 con.Close()
1774 End If
1775 End Sub
1776 Sub PrintHD_Kitchen()
1777 Dim CN As New OleDbConnection(cs)
1778 CN.Open()
1779 adp = New OleDbDataAdapter()
1780 adp.SelectCommand = New OleDbCommand("SELECT DISTINCT Kitchen.KitchenName FROM (((Dish INNER JOIN Kitchen ON Dish.Kitchen = Kitchen.KitchenName) INNER JOIN RestaurantBillingItems ON Dish.ItemID = RestaurantBillingItems.Item_ID) INNER JOIN RestaurantBillingInfo ON RestaurantBillingItems.B_ID = RestaurantBillingInfo.BillID) where BillID=" & lblBillNo.Text & "", CN)
1781 ds = New DataSet("ds")
1782 adp.Fill(ds)
1783 Dim dtable As DataTable = ds.Tables(0)
1784 CBox.Items.Clear()
1785 For Each drow As DataRow In dtable.Rows
1786 CBox.Items.Add(drow(0).ToString())
1787 Next
1788 For Each item As String In CBox.Items
1789 Cursor = Cursors.WaitCursor
1790 Timer2.Enabled = True
1791 Dim rpt As New rptRestaurantPOSHDInvoice_Kitchen 'The report you created.
1792 Dim myConnection As OleDbConnection
1793 Dim MyCommand, MyCommand1 As New OleDbCommand()
1794 Dim myDA, myDA1 As New OleDbDataAdapter()
1795 Dim myDS As New DataSet 'The DataSet you created.
1796 myConnection = New OleDbConnection(cs)
1797 MyCommand.Connection = myConnection
1798 MyCommand1.Connection = myConnection
1799 MyCommand.CommandText = "SELECT RestaurantBillingInfo.BillId, RestaurantBillingInfo.BillType, RestaurantBillingInfo.BillDate, RestaurantBillingInfo.CustomerName, RestaurantBillingInfo.AddressLine1, RestaurantBillingInfo.AddressLine2,RestaurantBillingInfo.AddressLine3, RestaurantBillingInfo.ContactNo, RestaurantBillingInfo.PaymentMode, RestaurantBillingInfo.SubTotal, RestaurantBillingInfo.ItemDiscount, RestaurantBillingInfo.DiscountPer,RestaurantBillingInfo.Discount, RestaurantBillingInfo.VAT, RestaurantBillingInfo.ServiceTax, RestaurantBillingInfo.ServiceCharges, RestaurantBillingInfo.TACharges, RestaurantBillingInfo.HDCharges,RestaurantBillingInfo.GrandTotal, RestaurantBillingInfo.Cash, RestaurantBillingInfo.Change, RestaurantBillingInfo.OperatorID, RestaurantBillingInfo.BillNote, RestaurantBillingItems.P_ID,RestaurantBillingItems.B_ID, RestaurantBillingItems.Item_ID, RestaurantBillingItems.Qty, RestaurantBillingItems.Rate, RestaurantBillingItems.Amount, RestaurantBillingItems.DiscPer,RestaurantBillingItems.Disc, RestaurantBillingItems.VATPer, RestaurantBillingItems.VATAmt, RestaurantBillingItems.STPer, RestaurantBillingItems.STAmt, RestaurantBillingItems.SCPer,RestaurantBillingItems.SCAmt, RestaurantBillingItems.TotalAmt, RestaurantBillingItems.ItemNote, RestaurantBillingItems.TableNo, RestaurantBillingItems.GroupName, Dish.ItemID, Dish.Dishname,Dish.Category, Dish.Kitchen, Dish.InventoryType, Dish.Rate AS Expr1, Dish.Discount AS Expr2 FROM ((RestaurantBillingInfo INNER JOIN RestaurantBillingItems ON RestaurantBillingInfo.BillId = RestaurantBillingItems.B_ID) INNER JOIN Dish ON RestaurantBillingItems.Item_ID = Dish.ItemID) where BillID=" & lblBillNo.Text & ""
1800 MyCommand.Parameters.AddWithValue("@d1", item)
1801 MyCommand1.CommandText = "SELECT * from Hotel"
1802 MyCommand.CommandType = CommandType.Text
1803 MyCommand1.CommandType = CommandType.Text
1804 myDA.SelectCommand = MyCommand
1805 myDA1.SelectCommand = MyCommand1
1806 myDA.Fill(myDS, "RestaurantBillingInfo")
1807 myDA.Fill(myDS, "RestaurantBillingItems")
1808 myDA.Fill(myDS, "Dish")
1809 myDA1.Fill(myDS, "Hotel")
1810 rpt.SetDataSource(myDS)
1811 con = New OleDbConnection(cs)
1812 con.Open()
1813 cmd = con.CreateCommand()
1814 cmd.CommandText = "SELECT RTRIM(Printer) from Kitchen where KitchenName=@d1 and IsEnabled='Yes'"
1815 cmd.Parameters.AddWithValue("@d1", item)
1816 rdr = cmd.ExecuteReader()
1817 If rdr.Read() Then
1818 s1 = rdr.GetValue(0)
1819 rpt.PrintOptions.PrinterName = s1
1820 rpt.PrintToPrinter(1, False, 0, 0)
1821 End If
1822 If (rdr IsNot Nothing) Then
1823 rdr.Close()
1824 End If
1825 If con.State = ConnectionState.Open Then
1826 con.Close()
1827 End If
1828 Next
1829
1830 End Sub
1831 Sub Print4()
1832 PrintHD()
1833 PrintHD_Kitchen()
1834 End Sub
1835 Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
1836 Cursor = Cursors.Default
1837 Timer2.Enabled = False
1838 End Sub
1839
1840 'Private Sub cmbGroup_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbGroup.KeyDown
1841 ' If e.KeyCode = Keys.Enter Then
1842 ' e.SuppressKeyPress = True
1843 ' DataGridView2.BeginEdit(True)
1844 ' End If
1845 'End Sub
1846 End Class